package com.mediacloud.app.newsmodule.activity

import android.os.Bundle
import android.webkit.WebView
import com.mediacloud.app.model.activity.BaseBackActivity
import com.mediacloud.app.model.view.WebBrowser
import com.mediacloud.app.newsmodule.R
import com.mediacloud.app.newsmodule.fragment.webview.WebViewFragment
import com.mediacloud.app.newsmodule.utils.MJavaScriptInterface
import com.mediacloud.app.newsmodule.utils.XinZHiJavaScriptInterface
import com.mediacloud.app.reslib.enums.AppFactoryGlobalConfig
import kotlinx.android.synthetic.main.activity_weather_h5.*

/**
 * 外链天气详情
 */
class WeatherDetailH5Activity : BaseBackActivity() {
    override fun getLayoutResID(): Int {
        return R.layout.activity_weather_h5
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mWebBrowser.addJavascriptInterface(XinZHiJavaScriptInterface(), "xin_zhi")
        val mInterface = MJavaScriptInterface(this, mWebBrowser)
        mWebBrowser.addJavascriptInterface(mInterface, WebViewFragment.GETMFSIGN)
        mWebBrowser.addJavascriptInterface(mInterface, WebViewFragment.ANDROID)
        mWebBrowser.loadUrl(intent.getStringExtra("WEATHER_URL")!!)
        mWebBrowser.setWebViewClient(object :WebBrowser.WebClient(this,mWebBrowser){
            override fun onPageFinished(view: WebView?, url: String?) {
                super.onPageFinished(view, url)
                setTitle(view?.title)
            }
        })
    }
}